// VBConversions Note: VB project level imports
using System.Collections.Generic;
using System;
using System.Linq;
using System.Drawing;
using System.Diagnostics;
using Microsoft.VisualBasic;
using System.Xml.Linq;
using Microsoft.VisualBasic.Compatibility;
using System.Windows.Forms;
using System.Collections;
using System.Data;
// End of VB project level imports

using System.IO;

namespace 喷码数据生成工具
{
	public partial class Form1
	{
		public Form1()
		{
			// VBConversions Note: Non-static class variable initialization is below.  Class variables cannot be initially assigned non-static values in C#.
			frmList = new frm_SettingList(this);
			
			InitializeComponent();
			
			//Added to support default instance behavour in C#
			if (defaultInstance == null)
				defaultInstance = this;
		}
		
#region Default Instance
		
		private static Form1 defaultInstance;
		
		/// <summary>
		/// Added by the VB.Net to C# Converter to support default instance behavour in C#
		/// </summary>
public static Form1 Default
		{
			get
			{
				if (defaultInstance == null)
				{
					defaultInstance = new Form1();
					defaultInstance.FormClosed += new FormClosedEventHandler(defaultInstance_FormClosed);
				}
				
				return defaultInstance;
			}
			set
			{
				defaultInstance = value;
			}
		}
		
		static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e)
		{
			defaultInstance = null;
		}
		
#endregion
		//Dim ParentPage As New System.Windows.Forms.TabPage("Row1")
		public struct TabObject
		{
			public Label 起始号标签;
			public ComboBox 起始号;
			public Label 终止号标签;
			public ComboBox 终止号;
			public Label 步长标签;
			public TextBox 步长;
			public Label 长度标签;
			public TextBox 长度;
			public Label 校验标签;
			public ComboBox 校验方式;
			public Label 前缀标签;
			public TextBox 前缀;
			public Label 后缀标签;
			public TextBox 后缀;
			public Label 插入字符标签;
			public TextBox 插入字符;
			public Label 字符位置标签;
			public Label 字符标签;
			public TextBox[] 字符位置;
			public TextBox[] 字符;
			public CheckBox 固定信息;
			public CheckBox 本号计算;
			public CheckBox 显示封面页;
			public object ExportData1; //存储扩展信息1
			public object ExportData2; //存储扩展信息2
		}
		DataSet ds;
		private const int MaxHeight = 646;
		private const int MinHeight = 625;
		private delegate void CreateDataInvoke();
		private delegate void ChangeStateInvoke(long Value, int DRowCount, int LineCount);
		private delegate void ChangeProgMaxInvoke(long mMax);
		private delegate void EndOfCreateInvoke();
		private delegate void ChangeStartIndexInvoke(long Value);
		private delegate string  InvokeGetLastString(int LineP, int TabCount, long Index, long CreatedCount, DataTable CreateDataTable);
		private delegate void ChangeEndProgressState(long value, long ProgressValue2, int DRowCount, int LineCount);
		private delegate void InvokeShowFirstIndex(int Value);
		frmSearchData SearchFrm;
		CheckCode AlreadyWriteCode = new CheckCode();
		bool CreattingData = false;
		bool StopCreate = false;
		System.Threading.Thread th;
		MSScriptControl.ScriptControl DownLoadData_Script = new MSScriptControl.ScriptControl();
		frmCheckData frmCheckData = new frmCheckData();
		CommFunction.SaveSetting CurrentTabData;
		gdToolStrip ToolStrip = new gdToolStrip();
		ChangeValueParam ChangeParam = new ChangeValueParam();
		bool StopCreattingData = false;
		bool CaculateCell = false;
		//===========
		frmConversion frm_Convert = new frmConversion();
		frm_SettingList frmList; // VBConversions Note: Initial value cannot be assigned here since it is non-static.  Assignment has been moved to the class constructors.
		int Me_Left;
		int Me_Top;
		frm_DHL frm_DHLObj = new frm_DHL();
		public void Form1_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
		{
			if (CreattingData == true)
			{
				if (Interaction.MsgBox("正在生成数据，是否继续退出程序?", (int) MsgBoxStyle.Question + MsgBoxStyle.YesNo, "询问") == MsgBoxResult.Yes)
				{
					StopCreate = true;
					th.Abort();
					goto QuitLine;
				}
				else
				{
					e.Cancel = true;
					return ;
				}
			}
			if (CommFunction.SaveEditeHandle.Count > 0)
			{
				if (MessageBox.Show(this, "有文本编辑器未关闭，为保证数据不丢失请注意保存数据，是否先关闭文本编辑器？", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == Windows.Forms.DialogResult.Yes)
				{
					e.Cancel = true;
					return ;
				}
				else
				{
					goto QuitLine;
				}
			}
QuitLine:
			e.Cancel = true;
			
			SaveSetting();
			try
			{
				CommFunction.Sql.Close();
				CommFunction.Sql.Dispose();
			}
			catch (Exception)
			{
			}
			e.Cancel = false;
		}
		public void Form1_Load(System.Object sender, System.EventArgs e)
		{
			try
			{
				CommFunction.CheckScript.Language = "VBScript";
				object null_object = null;
				CommFunction.CheckScript.Modules.Add("CheckMode", ref null_object);
				LoadSettingFromFile();
				CommFunction.LoadCheckMode();
				CommFunction.Registration();
				RowTab.TabPages.RemoveAt(0);
				ds = CreateTable();
				DataView.DataSource = ds.Tables[0].DefaultView;
				AddTabPage(null);
				CH_AddLine.Checked = false;
				TB_LinePosition.Text = System.Convert.ToString(50);
				TB_LinePosition.Enabled = false;
				Txt_Lines.Text = "1";
				DataView.Columns[0].Width = 30;
				DataView.Columns[1].Width = 130;
				DataView.Columns[2].Width = 130;
				DataView.Columns[3].Width = 60;
				DataView.Columns[4].Width = 60;
				DataView.Columns[5].Width = 60;
				DataView.Columns[6].Width = 60;
				DataView.Columns[7].Width = 60;
				DataView.Columns[8].Width = 60;
				DataView.Columns[9].Width = 55;
				DataGridViewCellStyle cellstyle = new DataGridViewCellStyle();
				cellstyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
				DataView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
				DataView.ColumnHeadersHeight = 30;
				DataView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
				DataView.ColumnHeadersDefaultCellStyle = cellstyle;
				DataView.Columns[0].Frozen = true;
				DataView.Columns[0].Resizable = DataGridViewTriState.False;
				DataView.Columns[0].ReadOnly = true;
				DataView.Columns[9].ReadOnly = true;
				DataView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
				for (var i = 0; i <= DataView.Columns.Count - 1; i++)
				{
					DataView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
				}
				DataView.RowHeadersWidth = 30;
				DataView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
				this.MenuStrip1.Renderer = CommFunction.MenuSkinRender;
				LoadMenuColor();
				this.Text = Application.ProductName + "[未连接数据库]";
				DownLoadData_Script.Language = "VBScript";
				this.Height = MinHeight;
				Me_Left = this.Left;
				Me_Top = this.Top;
				Progress1.Value = 0;
				Progress2.Value = 0;
				LoadTabSetting();
			}
			catch (Exception ex)
			{
				Interaction.MsgBox(ex.Message, MsgBoxStyle.Information, "提示");
			}
		}
#region 添加行数Tab
		private void AddTabPage(int index)
		{
			TabObject AddData = new TabObject();
			int WidthEffect = 5;
			int Topeffect = 15;
			int TxtHeight = 180;
			int txtWidth = 120;
			NewTab tmpTabPage = null;
			if (index == 0)
			{
				tmpTabPage = new NewTab();
				RowTab.TabPages.Add(tmpTabPage);
			}
			else
			{
				if (index >= RowTab.TabPages.Count)
				{
					tmpTabPage = new NewTab();
					RowTab.TabPages.Add(tmpTabPage);
				}
			}
			if (tmpTabPage != null)
			{
				AddData.起始号标签 = new Label();
				AddData.起始号标签.Text = "起始号码";
				AddData.起始号 = new ComboBox();
				AddData.终止号标签 = new Label();
				AddData.终止号标签.Text = "终止号码";
				AddData.终止号 = new ComboBox();
				AddData.步长标签 = new Label();
				AddData.步长标签.Text = "步长值";
				AddData.步长 = new TextBox();
				AddData.长度标签 = new Label();
				AddData.长度标签.Text = "号码长度";
				AddData.长度 = new TextBox();
				AddData.校验标签 = new Label();
				AddData.校验标签.Text = "校验方式";
				AddData.校验方式 = new ComboBox();
				AddData.前缀标签 = new Label();
				AddData.前缀标签.Text = "前缀";
				AddData.前缀 = new TextBox();
				AddData.后缀标签 = new Label();
				AddData.后缀 = new TextBox();
				AddData.后缀标签.Text = "后缀";
				AddData.插入字符标签 = new Label();
				AddData.插入字符标签.Text = "插入字符";
				AddData.插入字符 = new TextBox();
				AddData.字符位置标签 = new Label();
				AddData.字符位置标签.Text = "插入位置";
				AddData.本号计算 = new CheckBox();
				AddData.本号计算.Text = "本号计算";
				AddData.字符位置 = new TextBox[7];
				AddData.字符标签 = new Label();
				AddData.字符标签.Text = "插入字符";
				AddData.字符 = new TextBox[7];
				AddData.固定信息 = new CheckBox();
				AddData.显示封面页 = new CheckBox();
				AddData.显示封面页.Text = "显示封面页";
				tmpTabPage.Controls.Add(AddData.起始号标签);
				AddData.起始号标签.Left = WidthEffect;
				AddData.起始号标签.Top = 10;
				SetLabel(AddData.起始号标签);
				tmpTabPage.Controls.Add(AddData.起始号);
				AddData.起始号.Width = txtWidth;
				AddData.起始号.Left = AddData.起始号标签.Left + AddData.起始号标签.Width;
				AddData.起始号.Top = (int) (AddData.起始号标签.Top + (double) (AddData.起始号标签.Height - AddData.起始号.Height) / 2);
				tmpTabPage.Controls.Add(AddData.终止号标签);
				SetLabel(AddData.终止号标签);
				AddData.终止号标签.Left = AddData.起始号.Left + AddData.起始号.Width + WidthEffect;
				AddData.终止号标签.Top = AddData.起始号标签.Top;
				tmpTabPage.Controls.Add(AddData.终止号);
				AddData.终止号.Width = txtWidth;
				AddData.终止号.Left = AddData.终止号标签.Left + AddData.终止号标签.Width + WidthEffect;
				AddData.终止号.Top = (int) (AddData.终止号标签.Top + (double) (AddData.终止号标签.Height - AddData.终止号.Height) / 2);
				tmpTabPage.Controls.Add(AddData.步长标签);
				SetLabel(AddData.步长标签);
				AddData.步长标签.Left = AddData.起始号标签.Left;
				AddData.步长标签.Top = AddData.起始号标签.Top + AddData.起始号标签.Height + Topeffect;
				tmpTabPage.Controls.Add(AddData.步长);
				AddData.步长.Width = AddData.起始号.Width;
				AddData.步长.Height = TxtHeight;
				AddData.步长.Left = AddData.起始号.Left;
				AddData.步长.Top = (int) (AddData.步长标签.Top + (double) (AddData.步长标签.Height - AddData.步长.Height) / 2);
				tmpTabPage.Controls.Add(AddData.长度标签);
				SetLabel(AddData.长度标签);
				MoveObj(AddData.长度标签, AddData.步长.Left + AddData.步长.Width + WidthEffect, AddData.步长.Top + (double) (AddData.步长.Height - AddData.长度标签.Height) / 2);
				
				tmpTabPage.Controls.Add(AddData.长度);
				MoveObj(AddData.长度, AddData.长度标签.Left + AddData.长度标签.Width + WidthEffect, AddData.长度标签.Top + (double) (AddData.长度标签.Height - AddData.长度.Height) / 2, txtWidth, TxtHeight);
				
				tmpTabPage.Controls.Add(AddData.校验标签);
				SetLabel(AddData.校验标签);
				MoveObj(AddData.校验标签, AddData.起始号标签.Left, AddData.长度标签.Top + AddData.长度标签.Height + Topeffect);
				tmpTabPage.Controls.Add(AddData.校验方式);
				MoveObj(AddData.校验方式, AddData.校验标签.Left + AddData.校验标签.Width, AddData.校验标签.Top + (double) (AddData.校验标签.Height - AddData.校验方式.Height) / 2, txtWidth * 2 + 65);
				tmpTabPage.Controls.Add(AddData.前缀标签);
				SetLabel(AddData.前缀标签);
				MoveObj(AddData.前缀标签, AddData.校验标签.Left, AddData.校验标签.Top + AddData.校验标签.Height + Topeffect);
				tmpTabPage.Controls.Add(AddData.前缀);
				MoveObj(AddData.前缀, AddData.校验方式.Left, AddData.前缀标签.Top + (double) (AddData.前缀标签.Height - AddData.前缀.Height) / 2, AddData.校验方式.Width, TxtHeight);
				tmpTabPage.Controls.Add(AddData.后缀标签);
				SetLabel(AddData.后缀标签);
				MoveObj(AddData.后缀标签, AddData.前缀标签.Left, AddData.前缀标签.Top + AddData.前缀标签.Height + Topeffect);
				tmpTabPage.Controls.Add(AddData.后缀);
				MoveObj(AddData.后缀, AddData.前缀.Left, AddData.后缀标签.Top + (double) (AddData.后缀标签.Height - AddData.后缀.Height) / 2, AddData.前缀.Width, TxtHeight);
				tmpTabPage.Controls.Add(AddData.插入字符标签);
				SetLabel(AddData.插入字符标签);
				MoveObj(AddData.插入字符标签, AddData.后缀标签.Left, AddData.后缀标签.Top + AddData.后缀标签.Height + Topeffect);
				tmpTabPage.Controls.Add(AddData.插入字符);
				MoveObj(AddData.插入字符, AddData.后缀.Left, AddData.插入字符标签.Top + (double) (AddData.插入字符标签.Height - AddData.插入字符.Height) / 2, AddData.后缀.Width, TxtHeight);
				tmpTabPage.Controls.Add(AddData.字符位置标签);
				SetLabel(AddData.字符位置标签);
				MoveObj(AddData.字符位置标签, AddData.插入字符标签.Left, AddData.插入字符标签.Top + AddData.插入字符标签.Height + Topeffect);
				tmpTabPage.Controls.Add(AddData.字符标签);
				SetLabel(AddData.字符标签);
				MoveObj(AddData.字符标签, AddData.字符位置标签.Left, AddData.字符位置标签.Top + AddData.字符位置标签.Height + Topeffect);
				
				int lc = AddData.字符位置.Length;
				int lW = (int) ((double) (AddData.后缀.Width - lc * 6) / lc);
				int lt = (int) (AddData.字符位置标签.Top + (double) (AddData.字符位置标签.Height - AddData.后缀.Height) / 2);
				int pt = (int) (AddData.字符标签.Top + (double) (AddData.字符标签.Height - AddData.后缀.Height) / 2);
				for (var i = 0; i <= lc - 1; i++)
				{
					AddData.字符位置[(int) i] = new TextBox();
					tmpTabPage.Controls.Add(AddData.字符位置[(int) i]);
					MoveObj(AddData.字符位置[(int) i], AddData.后缀.Left + i * lW + 5 * i, lt, lW, TxtHeight);
					AddData.字符位置[(int) i].KeyPress += HandleHanShuAndLengthKeyPress;
					AddData.字符[(int) i] = new TextBox();
					tmpTabPage.Controls.Add(AddData.字符[(int) i]);
					MoveObj(AddData.字符[(int) i], AddData.后缀.Left + i * lW + 5 * i, pt, lW, TxtHeight);
				}
				AddData.校验方式.DropDownStyle = ComboBoxStyle.DropDownList;
				AddCheckName(AddData.校验方式);
				if (index == 0)
				{
					AddData.终止号标签.Text = "终止号码";
					AddSelect(AddData.起始号);
					AddSelect(AddData.终止号);
					AddData.起始号.SelectedIndex = 0;
					AddData.终止号.SelectedIndex = 1;
					AddData.起始号.DropDownStyle = ComboBoxStyle.DropDownList;
					AddData.终止号.DropDownStyle = ComboBoxStyle.DropDownList;
					AddData.步长.Text = System.Convert.ToString(1);
					AddData.长度.Text = System.Convert.ToString(8);
					AddData.校验方式.SelectedIndex = 0;
					AddData.终止号.Enabled = false;
					AddData.起始号.Enabled = false;
				}
				else
				{
					AddData.终止号标签.Text = "行数";
					AddSelect(AddData.起始号);
					if (((NewTab) (RowTab.TabPages[index - 1])).AtactchData != null)
					{
						AddData.起始号.SelectedIndex = System.Convert.ToInt32(((NewTab) (RowTab.TabPages[index - 1])).AtactchData.起始号.SelectedIndex);
						AddData.步长.Text = System.Convert.ToString(((NewTab) (RowTab.TabPages[index - 1])).AtactchData.步长.Text);
						if (index > 1)
						{
							AddData.终止号.Text = System.Convert.ToString(((NewTab) (RowTab.TabPages[index - 1])).AtactchData.终止号.Text);
						}
						else
						{
							AddData.终止号.Text = System.Convert.ToString(1);
						}
						AddData.长度.Text = System.Convert.ToString(((NewTab) (RowTab.TabPages[index - 1])).AtactchData.长度.Text);
						AddData.校验方式.SelectedIndex = ((TabObject) (((NewTab) (RowTab.TabPages[index - 1])).AtactchData)).校验方式.SelectedIndex;
						AddData.前缀.Text = ((TabObject) (((NewTab) (RowTab.TabPages[index - 1])).AtactchData)).前缀.Text;
						AddData.后缀.Text = ((TabObject) (((NewTab) (RowTab.TabPages[index - 1])).AtactchData)).后缀.Text;
					}
					else
					{
						AddData.起始号.SelectedIndex = 0;
					}
					AddData.起始号.DropDownStyle = ComboBoxStyle.DropDownList;
					
				}
				if (index > 0)
				{
					tmpTabPage.Controls.Add(AddData.固定信息);
					AddData.固定信息.Text = "固定文本";
					AddData.固定信息.AutoSize = true;
					MoveObj(AddData.固定信息, AddData.后缀.Left + AddData.后缀.Width - AddData.固定信息.Width, AddData.字符标签.Top + AddData.字符标签.Height + Topeffect + 5);
					tmpTabPage.Controls.Add(AddData.本号计算);
					MoveObj(AddData.本号计算, AddData.后缀.Left, AddData.字符标签.Top + AddData.字符标签.Height + Topeffect);
					tmpTabPage.Controls.Add(AddData.显示封面页);
					MoveObj(AddData.显示封面页, AddData.本号计算.Left + 110, AddData.本号计算.Top);
					AddData.显示封面页.Visible = false;
				}
				//handle event挂起文本框输入动作事件
				AddData.终止号.TextChanged += HandleTextChange;
				AddData.终止号.KeyPress += HandleHanShuAndLengthKeyPress;
				AddData.长度.KeyPress += HandleHanShuAndLengthKeyPress;
				AddData.步长.KeyPress += HandleBCKeyPress;
				AddData.步长.KeyUp += HandleBCkeyUp;
				AddData.校验方式.SelectedIndexChanged += HandleCheckModeSelectedChanged;
				if (index > 0)
				{
					AddData.本号计算.CheckedChanged += HandleBHCheckChanged;
					AddData.固定信息.CheckedChanged += HandleGDXINXICheckChanged;
					if (Conversion.Val(AddData.终止号.Text) > 1)
					{
						tmpTabPage.Text = "Row" + System.Convert.ToString(RowTab.TabPages.Count) + "_" + AddData.终止号.Text;
					}
					else
					{
						tmpTabPage.Text = "Row" + System.Convert.ToString(RowTab.TabPages.Count);
					}
				}
				else
				{
					tmpTabPage.Text = "Row" + System.Convert.ToString(RowTab.TabPages.Count);
				}
				tmpTabPage.BackColor = Color.White;
				tmpTabPage.Tag = AddData;
				tmpTabPage.AtactchData = AddData;
			}
		}
		private void RemoveTab()
		{
			if (RowTab.TabPages.Count > 1)
			{
				RowTab.TabPages.RemoveAt(RowTab.TabPages.Count - 1);
				RowTab.SelectedIndex = RowTab.TabPages.Count - 1;
			}
		}
		private void MoveObj(Control obj, int sLeft, int wTop, int sWidth = 0, int sHeight = 0)
		{
			try
			{
				if (sWidth > 0)
				{
					obj.Width = sWidth;
				}
				if (sHeight > 0)
				{
					obj.Height = sHeight;
				}
				obj.Left = sLeft;
				obj.Top = wTop;
			}
			catch (Exception)
			{
				
			}
		}
		private void SetLabel(Label obj)
		{
			Label with_1 = obj;
			with_1.AutoSize = true;
			with_1.BackColor = Color.Transparent;
		}
		public void Btn_Add_Click(System.Object sender, System.EventArgs e)
		{
			AddTabPage(RowTab.TabPages.Count);
			RowTab.SelectedIndex = RowTab.TabPages.Count - 1;
		}
		
		public void Btn_Del_Click(System.Object sender, System.EventArgs e)
		{
			RemoveTab();
			HandleTextChange(sender, e);
		}
		private DataSet CreateTable()
		{
			DataSet rs = new DataSet("Data");
			DataTable Table = new DataTable("DataTable");
			System.Type DataType = default(System.Type);
			System.Type StringType = System.Type.GetType("System.String");
			DataType = System.Type.GetType("System.Int64");
			Table.Columns.Add("ID", DataType, "");
			Table.Columns.Add("起始号码", DataType, "");
			Table.Columns.Add("终止号码", DataType, "");
			Table.Columns.Add("数量", DataType, "");
			Table.Columns.Add("站点", StringType, "");
			Table.Columns.Add("文本1", StringType, "");
			Table.Columns.Add("文本2", StringType, "");
			Table.Columns.Add("文本3", StringType, "");
			Table.Columns.Add("文本4", StringType, "");
			Table.Columns.Add("状态", StringType, "");
			rs.Tables.Add(Table);
			return rs;
		}
		private void AddSelect(ComboBox obj)
		{
			int c = DataView.Columns.Count - 1;
			for (var i = 1; i <= c - 1; i++)
			{
				obj.Items.Add(DataView.Columns[i].HeaderText);
			}
		}
		private void AddCheckName(ComboBox obj)
		{
			if (CommFunction.CheckData != null)
			{
				if (CommFunction.CheckData.Count > 0)
				{
					for (var i = 0; i <= CommFunction.CheckData.Count - 1; i++)
					{
						obj.Items.Add(CommFunction.CheckData[System.Convert.ToInt32(i)].CheckName);
					}
				}
			}
		}
#endregion
#region 文本框输入行为控制
		private void HandleBHCheckChanged(object sender, EventArgs e)
		{
			bool v = ((CheckBox) sender).Checked;
			int TabIndex = RowTab.SelectedIndex;
			if (v == true)
			{
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).固定信息.Checked = false;
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).前缀标签.Text = "起始本号";
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).显示封面页.Visible = true;
			}
			else
			{
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).前缀标签.Text = "前缀";
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).显示封面页.Visible = false;
			}
		}
		private void HandleGDXINXICheckChanged(object sender, EventArgs e)
		{
			bool v = ((CheckBox) sender).Checked;
			if (v == true)
			{
				int TabIndex = RowTab.SelectedIndex;
				((TabObject) (((NewTab) (RowTab.TabPages[TabIndex])).AtactchData)).本号计算.Checked = false;
			}
		}
		private void HandleHanShuAndLengthKeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if (Strings.Asc(e.KeyChar) != 8)
			{
				if (Strings.Asc(e.KeyChar) < 48 || Strings.Asc(e.KeyChar) > 57)
				{
					e.Handled = true;
				}
			}
		}
		private void HandleBCKeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if (Strings.Asc(e.KeyChar) != 8)
			{
				if (Strings.Asc(e.KeyChar) < 48 || Strings.Asc(e.KeyChar) > 57)
				{
					if (Strings.Asc(e.KeyChar) != 45)
					{
						e.Handled = true;
					}
					else
					{
						TextBox tmpobj = sender;
						string tmp = "";
						if (tmpobj.Text.IndexOf("-") >= 0)
						{
							tmp = tmpobj.Text.Replace("-", "");
							((TextBox) sender).Text = "-" + tmp;
							e.Handled = true;
						}
						else
						{
							((TextBox) sender).Text = "-" + tmpobj.Text;
							e.Handled = true;
						}
					}
				}
			}
		}
		private void HandleBCkeyUp(System.Object sender, System.Windows.Forms.KeyEventArgs e)
		{
			string tmp = ((TextBox) sender).Text;
			if (tmp.IndexOf("-") > 0)
			{
				tmp = tmp.Replace("-", "");
				((TextBox) sender).Text = "-" + tmp;
			}
			int StepV = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
			if (DataView.Rows.Count >= 2 & StepV != 0) //步长值变化，重新计算号码总数
			{
				for (var i = 0; i <= DataView.Rows.Count - 2; i++)
				{
					try
					{
						long st = 0;
						long ft = 0;
						try
						{
							st = Convert.ToInt64(DataView.Rows[i].Cells[1].Value);
						}
						catch
						{
							st = 0;
						}
						try
						{
							ft = Convert.ToInt64(DataView.Rows[i].Cells[2].Value);
						}
						catch
						{
							ft = 0;
						}
						if (st != 0 & ft != 0)
						{
							if (st < ft)
							{
								DataView.Rows[i].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) + 1);
							}
							else
							{
								DataView.Rows[i].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) - 1);
							}
						}
						else if (st == 0 & ft != 0)
						{
							DataView.Rows[i].Cells[3].Value = 1;
						}
						else if (st != 0 & ft == 0)
						{
							DataView.Rows[i].Cells[3].Value = 1;
						}
						else if (st == 0 & ft == 0)
						{
							DataView.Rows[i].Cells[3].Value = 0;
						}
					}
					catch
					{
					}
				}
			}
		}
		private void HandleTextChange(object sender, EventArgs e)
		{
			string txt = "";
			int Max = 1;
			if (RowTab.TabPages.Count >= 1)
			{
				for (var i = 0; i <= RowTab.TabPages.Count - 1; i++)
				{
					txt = ((TabObject) (((NewTab) (RowTab.TabPages[i])).AtactchData)).终止号.Text;
					if (txt != "")
					{
						if (Conversion.Val(txt) > Max)
						{
							Max = (int) (Conversion.Val(txt));
						}
						if (Conversion.Val(txt) > 1)
						{
							RowTab.TabPages[i].Text = "Row" + (i + 1) + "_" + txt;
						}
						else
						{
							RowTab.TabPages[i].Text = "Row" + (i + 1);
						}
					}
				}
				Txt_Lines.Text = System.Convert.ToString(Max);
				if (Conversion.Val(txt) > 1)
				{
					((NewTab) (RowTab.TabPages[RowTab.SelectedIndex])).Text = "Row" + System.Convert.ToString(RowTab.SelectedIndex + 1) + "_" + txt;
				}
			}
		}
		private void HandleCheckModeSelectedChanged(System.Object sender, System.EventArgs e)
		{
			string CheckName = ((ComboBox) sender).Text;
			CommFunction.CheckMode CheckD = getCheckFunName(CheckName);
			CheckDescription.Text = CheckD.CheckDescription;
		}
#endregion
		public void CH_AddLine_CheckedChanged(System.Object sender, System.EventArgs e)
		{
			TB_LinePosition.Enabled = CH_AddLine.Checked;
			if (CH_AddLine.Checked == true)
			{
				NoWrap.Checked = false;
			}
		}
		
		public void NoWrap_CheckedChanged(System.Object sender, System.EventArgs e)
		{
			if (NoWrap.Checked)
			{
				CH_AddLine.Checked = false;
			}
			TB_BHlineCount.Enabled = NoWrap.Checked;
		}
#region 加载保存设置
		public void LoadSettingFromFile()
		{
			string sFileName = CommFunction.getTmpPath() + "\\gdTengen\\Config.data";
			System.IO.DirectoryInfo sInfo = Directory.GetParent(sFileName);
			string sPath = sInfo.FullName;
			byte[] sData = null;
			if (Directory.Exists(sPath) == false)
			{
				Directory.CreateDirectory(sPath);
			}
			if (File.Exists(sFileName) == true)
			{
				sData = File.ReadAllBytes(sFileName);
				try
				{
					CommFunction.SaveData = sAPI.BinToCmd(sData);
					if (Directory.Exists(CommFunction.SaveData.LastSaveFilePath))
					{
						if (CommFunction.SaveData.LastSaveFilePath.ToString().Substring(CommFunction.SaveData.LastSaveFilePath.ToString().Length - 1, 1) != "\\")
						{
							this.SaveFile.Text = CommFunction.SaveData.LastSaveFilePath + "\\1.txt";
						}
						else
						{
							this.SaveFile.Text = CommFunction.SaveData.LastSaveFilePath + "1.txt";
						}
					}
					else
					{
						if (Directory.GetCurrentDirectory().Substring(Directory.GetCurrentDirectory().Length - 1, 1) != "\\")
						{
							this.SaveFile.Text = Directory.GetCurrentDirectory() + "\\1.txt";
						}
						else
						{
							this.SaveFile.Text = Directory.GetCurrentDirectory() + "1.txt";
						}
						CommFunction.SaveData.LastSaveFilePath = Directory.GetCurrentDirectory();
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
			else
			{
				if (Directory.GetCurrentDirectory().Substring(Directory.GetCurrentDirectory().Length - 1, 1) != "\\")
				{
					this.SaveFile.Text = Directory.GetCurrentDirectory() + "\\1.txt";
				}
				else
				{
					this.SaveFile.Text = Directory.GetCurrentDirectory() + "1.txt";
				}
				CommFunction.SaveData.LastSaveFilePath = Directory.GetCurrentDirectory();
			}
			if (CommFunction.SaveData.Setting != null)
			{
				if (CommFunction.SaveData.Setting.Count <= 0)
				{
					Tool_ListButton.Enabled = false;
				}
				else
				{
					Tool_ListButton.Enabled = true;
				}
			}
			else
			{
				Tool_ListButton.Enabled = false;
			}
		}
		public void SaveSetting()
		{
			try
			{
				string sFileName = CommFunction.getTmpPath() + "\\gdTengen\\Config.data";
				System.IO.DirectoryInfo sInfo = Directory.GetParent(sFileName);
				string sPath = sInfo.FullName;
				byte[] sData = null;
				if (Directory.Exists(sPath) == false)
				{
					Directory.CreateDirectory(sPath);
				}
				sData = sAPI.CmdToBin(CommFunction.SaveData);
				File.WriteAllBytes(sFileName, sData);
			}
			catch (Exception ex)
			{
				Interaction.MsgBox(ex.Message, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "错误");
			}
		}
#endregion
		public void Btn_OpenFile_Click(System.Object sender, System.EventArgs e)
		{
			DirectoryInfo sInfo = default(DirectoryInfo);
			SaveFileDialog.Title = "保存";
			SaveFileDialog.CheckPathExists = true;
			SaveFileDialog.FileName = "1.txt";
			SaveFileDialog.Filter = "文本文件(*.txt)|*.txt";
			sInfo = Directory.GetParent(SaveFile.Text);
			SaveFileDialog.InitialDirectory = sInfo.FullName;
			if (SaveFileDialog.ShowDialog(this) == Windows.Forms.DialogResult.OK)
			{
				if (SaveFileDialog.FileName != "")
				{
					SaveFile.Text = SaveFileDialog.FileName;
					sInfo = Directory.GetParent(SaveFileDialog.FileName);
					CommFunction.SaveData.LastSaveFilePath = sInfo.FullName;
				}
			}
		}
		
		public void DataView_DataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			e.Cancel = true;
			Interaction.MsgBox(e.Exception.Message + "\r\n" + System.Convert.ToString(e.RowIndex), (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "错误");
		}
		
		public void DataView_RowsAdded(object sender, System.Windows.Forms.DataGridViewRowsAddedEventArgs e)
		{
			try
			{
				for (var i = 0; i <= DataView.Rows.Count - 1; i++)
				{
					DataView.Rows[i].Cells[0].Value = i + 1;
				}
				long st = 0;
				long ft = 0;
				int StepV = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
				try
				{
					st = Convert.ToInt64(DataView.Rows[e.RowIndex].Cells[1].Value);
				}
				catch
				{
					st = 0;
				}
				try
				{
					ft = Convert.ToInt64(DataView.Rows[e.RowIndex].Cells[2].Value);
				}
				catch
				{
					ft = 0;
				}
				if (st != 0 & ft != 0)
				{
					if (st < ft)
					{
						DataView.Rows[e.RowIndex].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) + 1);
					}
					else
					{
						DataView.Rows[e.RowIndex].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) - 1);
					}
				}
				else if (st == 0 & ft != 0)
				{
					DataView.Rows[e.RowIndex].Cells[3].Value = 1;
				}
				else if (st != 0 & ft == 0)
				{
					DataView.Rows[e.RowIndex].Cells[3].Value = 1;
				}
				else if (st == 0 & ft == 0)
				{
					DataView.Rows[e.RowIndex].Cells[3].Value = 0;
				}
			}
			catch
			{
			}
		}
		
		public void Btn_CreateData_Click(System.Object sender, System.EventArgs e)
		{
			DirectoryInfo sInfo = default(DirectoryInfo);
			sInfo = Directory.GetParent(SaveFile.Text);
			if (Directory.Exists(sInfo.FullName) == false)
			{
				Directory.CreateDirectory(sInfo.FullName);
			}
			int dc = DataView.Rows.Count;
			if (dc <= 1)
			{
				Interaction.MsgBox("数据表中没有数据，请添加数据！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
			}
			return ;
//			if ((DataView.Rows.Count - 1) % (Conversion.Val(Txt_Lines.Text)) != 0)
//			{
//				Interaction.MsgBox("数据行数和设置不匹配！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
//				}
//				return ;
//				if (dc > Conversion.Val(Txt_Lines.Text) + 1)
//				{
//					this.Height = MaxHeight;
//					long MaxNum = 0;
//					int RowStep = (int) (Conversion.Val(Txt_Lines.Text));
//					for (var i = 0; i <= dc - 2; i += RowStep)
//					{
//						try
//						{
//							MaxNum += System.Convert.ToInt64(DataView.Rows[i].Cells[3].Value);
//							}
//							catch
//							{
//								}
//								}
//								this.Progress2.Maximum = MaxNum;
//								}
								//========================初始化当前已生成号码数据量，以及查找对应的校验码函数名
//								int tc = RowTab.TabPages.Count;
//								string LastFunName = Constants.vbNullString;
//								bool ErrC = false;
//								for (var j = 0; j <= tc - 1; j++)
//								{
//									try
//									{
//										TabObject tmpData = new TabObject();
//										tmpData = (TabObject) (((NewTab) (RowTab.TabPages[j])).AtactchData);
//										tmpData.ExportData1 = getCheckFunName(((TabObject) (((NewTab) (RowTab.TabPages[j])).AtactchData)).校验方式.Text);
//										tmpData.ExportData2 = 0;
										
//										if (!string.IsNullOrEmpty(LastFunName) && LastFunName != "无")
//										{
//											if (((TabObject) (((NewTab) (RowTab.TabPages[j])).AtactchData)).校验方式.SelectedIndex > 0 & tmpData.ExportData1 != null)
//											{
//												if (LastFunName.ToLower() != ((CommFunction.CheckMode) tmpData.ExportData1).CommFunction.CheckName.ToLower() && !string.IsNullOrEmpty(LastFunName))
//												{
//													ErrC = true;
//													}
//													}
//													LastFunName = ((TabObject) (((NewTab) (RowTab.TabPages[j])).AtactchData)).校验方式.Text;
//													}
//													else
//													{
//														LastFunName = ((TabObject) (((NewTab) (RowTab.TabPages[j])).AtactchData)).校验方式.Text;
//														}
//														((NewTab) (RowTab.TabPages[j])).AtactchData = tmpData;
//														}
//														catch
//														{
															
//															}
//															}
//															if (ErrC)
//															{
//																Interaction.MsgBox("选择了不同的校验方式！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
//																}
//																CommFunction.CheckMode checkObj = getCheckFunName(LastFunName);
//																if (checkObj.CodeMode.ToString() != "None")
//																{
//																	CommFunction.CheckScript.Language = System.Convert.ToString(checkObj.CodeMode.ToString());
//																	}
//																	if (AppendData.Checked == false)
//																	{
//																		if (File.Exists(SaveFile.Text))
//																		{
//																			if (Interaction.MsgBox("文件已经存在，是否覆盖原文件？", (int) MsgBoxStyle.YesNo + MsgBoxStyle.Question, "询问") == MsgBoxResult.Yes)
//																			{
																				//Kill(SaveFile.Text)
//																				}
//																				else
//																				{
//																					SaveFile.Text = CommFunction.getAddFileName(SaveFile.Text);
//																					}
//																					}
//																					}
//																					CurrentTabData = ReadCurrentSetting("CurrentData");
//																					ChangeObjEnabled(false);
//																					ChangeParam.ProgressValue2 = 1;
//																					Timer1.Interval = 1;
//																					Timer1.Enabled = true;
//																					StopCreattingData = false;
																					//If DirectCast(DirectCast(RowTab.TabPages(0), NewTab).AtactchData, TabObject).校验方式.Text = "中铁" Then MsgBox("校验方式存在问题，需和业务进行确认！")
//																					th = new System.Threading.Thread(new System.Threading.ThreadStart(CreateData));
//																					th.Start();
																				}
																				
																				public void 链接数据库ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					DES jm = new DES();
																					try
																					{
																						if (CommFunction.Sql.ConnectionState == ConnectionState.Connecting | CommFunction.Sql.ConnectionState == ConnectionState.Open)
																						{
																							CommFunction.Sql.Close();
																						}
																						CommFunction.Sql.ConnectDataBase(CommFunction.SaveData.DataBaseIP, CommFunction.SaveData.DataBasePort, CommFunction.SaveData.DataBaseUserName, jm.Decrypt(CommFunction.SaveData.DataBasePassword, "sJ235689"), CommFunction.SaveData.DataBase);
																						Interaction.MsgBox("数据库连接成功！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
																						this.Text = Application.ProductName + "[已连接数据库]";
																					}
																					catch (Exception ex)
																					{
																						Interaction.MsgBox(ex.Message, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "链接失败");
																					}
																				}
																				
																				public void 修改数据库地址ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					ModifyAddress.Default.ShowDialog(this);
																				}
#region 生成数据
																				public void CreateData()
																				{
																					int RowCount = DataView.Rows.Count - 1;
																					// If RowCount > 2 Then Me.Height = MaxHeight
																					long StartNum = 0;
																					long FinishNum = 0;
																					int StepValue = 0;
																					int Time1 = 0;
																					int Time2 = 0;
																					FileStream fs = default(FileStream);
																					StreamWriter fw = default(StreamWriter);
																					if (AppendData.Checked == false)
																					{
																						fs = new FileStream(SaveFile.Text, FileMode.Create, FileAccess.Write);
																					}
																					else
																					{
																						fs = new FileStream(SaveFile.Text, FileMode.Append, FileAccess.Write);
																					}
																					if (CB_ExportOutPut.Checked == false)
																					{
																						fw = new StreamWriter(fs, System.Text.Encoding.Default);
																					}
																					else
																					{
																						fw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("IBM437"));
																					}
																					int tc = RowTab.TabPages.Count;
																					long CreatedCount = 0;
																					string ZD = "";
																					try
																					{
																						StartNum = System.Convert.ToInt64(DataView.Rows[0].Cells[1].Value);
																						StepValue = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
																						if (StepValue == 0)
																						{
																							throw (new Exception("步长值不能设置为0！"));
																						}
																						int RowStep = (int) (Conversion.Val(this.Txt_Lines.Text));
																						CreattingData = true;
																						Time1 = CommFunction.GetTickCount();
																						for (var i = 0; i <= RowCount - 1; i += RowStep)
																						{
																							try
																							{
																								StartNum = System.Convert.ToInt64(DataView.Rows[i].Cells[1].Value);
																								FinishNum = System.Convert.ToInt64(DataView.Rows[i].Cells[2].Value);
																							}
																							catch (Exception ex)
																							{
																								Interaction.MsgBox("数据第【" + (i + 1) + "】行设置错误，起始号码或终止号码不能为空！" + "\r\n" + ex.Message, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "错误");
																								goto endOfForLoop;
																							}
																							if (StepValue > 0)
																							{
																								if (StartNum > FinishNum)
																								{
																									Interaction.MsgBox("数据第【" + (i + 1) + "】行设置错误，当步长值大于0时，起始号码必须小于终止号码！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
																								}
																								break;
																							}
																							else if (StepValue == 0)
																							{
																								Interaction.MsgBox("步长值不能设置为0！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
																								break;
																							}
																							else if (StepValue < 0)
																							{
																								if (StartNum < FinishNum)
																								{
																									Interaction.MsgBox("数据第【" + (i + 1) + "】行设置错误，当步长值小于0时，起始号码必须大于终止号码！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "提示");
																								}
																								break;
																							}
																							try
																							{
																								ZD = System.Convert.ToString(DataView.Rows[i].Cells[3].Value);
																							}
																							catch (Exception)
																							{
																								ZD = "";
																							}
																							CreateAllData(fw, StartNum, FinishNum, ZD, System.Convert.ToInt32(i), tc, RowStep, ref CreatedCount);
																							if (StopCreattingData == true)
																							{
																								break;
																							}
																						}
endOfForLoop:
																						fw.Close();
																						fs.Close();
																						Timer1.Enabled = false;
OutSub:
																						Time2 = CommFunction.GetTickCount();
																						CreattingData = false;
																						this.Invoke(new ChangeEndProgressState(ProgressSub), ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																						this.Invoke(new EndOfCreateInvoke(EndOfCreateData));
																						if (StopCreattingData == false)
																						{
																							Interaction.MsgBox("数据生成结束，共用时间：" + CommFunction.FormatTickCount(Time2 - Time1), (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
																						}
																						else
																						{
																							Interaction.MsgBox("数据生成被终止，共用时间：" + CommFunction.FormatTickCount(Time2 - Time1) + "\r\n" + "共生成【" + System.Convert.ToString(ChangeParam.ProgressValue2) + "】条记录。", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
																						}
																						ChangeParam.value = 0;
																						ChangeParam.ProgressValue2 = 0;
																						this.Invoke(new ChangeEndProgressState(ProgressSub), ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																						System.Threading.Thread th = System.Threading.Thread.CurrentThread;
																						th.Abort();
																					}
																					catch (Exception ex)
																					{
																						//Clipboard.SetText(ex.Message)
																						CreattingData = false;
																						Timer1.Enabled = false;
																						this.Invoke(new ChangeEndProgressState(ProgressSub), ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																						this.Invoke(new EndOfCreateInvoke(EndOfCreateData));
																						if (ex.Message != "正在中止线程。")
																						{
																							try
																							{
																								Interaction.MsgBox(ex.Message, (int) MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "错误");
																								ChangeParam.value = 0;
																								ChangeParam.ProgressValue2 = 0;
																								this.Invoke(new ChangeEndProgressState(ProgressSub), ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																								this.Invoke(new EndOfCreateInvoke(EndOfCreateData));
																								fw.Close();
																								fs.Close();
																							}
																							catch
																							{
																							}
																							System.Threading.Thread th = System.Threading.Thread.CurrentThread;
																							th.Abort();
																						}
																					}
																					// Me.Height = MinHeight
																				}
																				public void CreateAllData(StreamWriter WriteStreamObj, long StartNumber, long FinishNumber, object ZD, int LinePosition, int TabCount, int LineCount, ref long CreatedCount)
																				{
																					int StepV = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
																					if (StepV > 0)
																					{
																						this.Invoke(new ChangeProgMaxInvoke(ChangeProgMax), Math.Abs(System.Convert.ToInt32(FinishNumber - StartNumber) + 1));
																					}
																					else
																					{
																						this.Invoke(new ChangeProgMaxInvoke(ChangeProgMax), Math.Abs(System.Convert.ToInt32(FinishNumber - StartNumber) - 1));
																					}
																					string XHstr = "";
																					int Len1 = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).长度.Text));
																					string jiaoyanma = "";
																					string LastString = "";
																					long gIndex = 0;
																					int StopLine = (int) (Conversion.Val(TB_LinePosition.Text));
																					string Qianzhui = CommFunction.TranslateText(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).前缀.Text);
																					object jiaoyanObj = ((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).ExportData1;
																					string HouZhui = CommFunction.TranslateText(System.Convert.ToString(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).后缀.Text));
																					string Zifu = CommFunction.TranslateText(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).插入字符.Text);
																					int DRowCount = DataView.Rows.Count;
																					//  Dim Tmpds As New DataSet
																					DataTable rData = default(DataTable);
																					rData = ds.Tables[0];
																					for (var i = LinePosition; i <= LinePosition + LineCount - 1; i++)
																					{
																						DataView.Rows[i].Cells["状态"].Value = "正在生成";
																						if (i == LinePosition)
																						{
																							this.Invoke(new InvokeShowFirstIndex(ShowFirstIndex), i);
																						}
																					}
																					for (var i = StartNumber; i <= FinishNumber; i += StepV)
																					{
																						XHstr = System.Convert.ToString(CommFunction.FormatByLength(System.Convert.ToInt64(i), Len1));
																						jiaoyanma = getCheckNumber(jiaoyanObj, XHstr); //计算校验码
																						XHstr = XHstr + jiaoyanma;
																						XHstr = Qianzhui + XHstr; //加前缀
																						XHstr = XHstr + HouZhui; //加后缀
																						XHstr = InsertChar(XHstr, Zifu); //加插入字符
																						XHstr = InsertOnPosition(XHstr, 0); //在任意位置添加字符
																						LastString = System.Convert.ToString(this.Invoke(new InvokeGetLastString(getLastLineString), LinePosition, TabCount, gIndex, CreatedCount, rData));
																						gIndex++;
																						CreatedCount++;
																						if (CurrentTabData.是否补号 == false)
																						{
																							WriteStreamObj.WriteLine(XHstr + LastString);
																						}
																						else if (CurrentTabData.是否补号 == true)
																						{
																							if ((CreatedCount) % (Conversion.Val(System.Convert.ToString(CurrentTabData.补号每行号码个数))) != 0)
																							{
																								if ((CreatedCount) % (Conversion.Val(TB_BHlineCount.Text)) != 1)
																								{
																									WriteStreamObj.Write("," + "\u0022" + XHstr + "\u0022" + "," + LastString);
																								}
																								else
																								{
																									WriteStreamObj.Write('\u0022' + XHstr + "\u0022" + "," + LastString);
																								}
																							}
																							else
																							{
																								WriteStreamObj.Write("," + "\u0022" + XHstr + "\u0022" + "," + LastString + "\r\n");
																							}
																						}
																						if (CurrentTabData.是否加黑线)
																						{
																							if (CreatedCount % StopLine == 0)
																							{
																								WriteStreamObj.WriteLine("-------------------------------------------------------");
																							}
																							else
																							{
																								WriteStreamObj.WriteLine("");
																							}
																						}
																						//=========================以下为显示进度委托函数
																						if (StepV > 0)
																						{
																							this.Invoke(new ChangeStateInvoke(ChangeState), Math.Abs(System.Convert.ToInt32(i) - StartNumber + 1), DRowCount, LineCount);
																						}
																						else
																						{
																							this.Invoke(new ChangeStateInvoke(ChangeState), Math.Abs(System.Convert.ToInt32(i) - StartNumber - 1), DRowCount, LineCount);
																						}
																						if (StopCreattingData == true)
																						{
																							return;
																						}
																						//  My.Application.DoEvents()
																					}
																					for (var i = LinePosition; i <= LinePosition + LineCount - 1; i++)
																					{
																						DataView.Rows[i].Cells["状态"].Value = "已完成";
																					}
																				}
																				private CommFunction.CheckMode getCheckFunName(string CheckName)
																				{
																					CommFunction.CheckMode result = null;
																					if (CommFunction.CheckData != null)
																					{
																						if (CommFunction.CheckData.Count > 0)
																						{
																							for (var i = 0; i <= CommFunction.CheckData.Count - 1; i++)
																							{
																								if (Strings.UCase(System.Convert.ToString(CommFunction.CheckData[System.Convert.ToInt32(i)].CheckName)) == CheckName.ToUpper())
																								{
																									result = CommFunction.CheckData[System.Convert.ToInt32(i)];
																								}
																								break;
																							}
																							return result;
																						}
																						else
																						{
																							return null;
																						}
																					}
																					else
																					{
																						return null;
																					}
																				}
																				
																				
																				private void ChangeIndex(long value)
																				{
																					TabObject tmpData = ((NewTab) (RowTab.TabPages[0])).AtactchData;
																					tmpData.ExportData2 = value;
																					((NewTab) (RowTab.TabPages[0])).AtactchData = tmpData;
																				}
																				private void ChangeProgMax(long mMax)
																				{
																					Progress1.Maximum = mMax;
																				}
																				private void ShowFirstIndex(int value)
																				{
																					DataView.FirstDisplayedScrollingRowIndex = value;
																				}
																				private void ChangeState(long value, int DRowCount, int LineCount)
																				{
																					ChangeParam.value = value;
																					ChangeParam.DRowCount = DRowCount;
																					ChangeParam.LineCount = LineCount;
																					ChangeParam.ProgressValue2++;
																				}
																				private void ProgressSub(long value, long ProgressValue2, int DRowCount, int LineCount)
																				{
																					int tmpValue;
																					tmpValue = (int) Progress1.Value;
																					Progress1.Value = value;
																					if (DRowCount > LineCount + 1)
																					{
																						Progress2.Value = ProgressValue2;
																					}
																				}
																				private void EndOfCreateData()
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					this.Height = MinHeight;
																					Progress1.Value = 0;
																					Progress2.Value = 0;
																					ChangeObjEnabled(true);
																					ProgressSub(ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																				}
																				/// <summary>
																				/// 获取其他数据
																				/// </summary>
																				/// <param name="LineP">当前生成所到的数据行数</param>
																				/// <param name="TabCount">RowTab总行数</param>
																				/// <param name="Index">当前数据段生成的号码数据量</param>
																				/// <param name="CreatedCount">已经成数据的总数</param>
																				/// <param name="CreateDataTable">要生成的数据表</param>
																				/// <returns></returns>
																				/// <remarks></remarks>
																				private string getLastLineString(int LineP, int TabCount, long Index, long CreatedCount, DataTable CreateDataTable)
																				{
																					int dc = TabCount;
																					if (dc <= 1)
																					{
																						return "";
																					}
																					string StartText = "";
																					string TextCommand = "";
																					string Result = "";
																					string JiShuan = ""; //保存当前计算出的号码，并做格式化处理
																					long Value = 0;
																					int SetLine = 0;
																					try
																					{
																						for (var i = 1; i <= dc - 1; i++)
																						{
																							int StepV = 1; //保存当先Tab页的步长值
																							int NumberL = 0;
																							string JiaoYanma = "";
																							SetLine = System.Convert.ToInt32(CurrentTabData.Data[i].FinishNumberText); //Val(DirectCast(DirectCast(RowTab.TabPages(i), NewTab).AtactchData, TabObject).终止号.Text)
																							TextCommand = System.Convert.ToString(CurrentTabData.Data[i].StartNumberText); //DirectCast(DirectCast(RowTab.TabPages(i), NewTab).AtactchData, TabObject).起始号.Text
																							try
																							{
																								// StartText = CreateDataTable.Rows(LineP + (SetLine - 1)).Cells(TextCommand).Value
																								StartText = System.Convert.ToString(CreateDataTable.Rows[LineP + (SetLine - 1)][TextCommand]);
																							}
																							catch
																							{
																								StartText = "";
																							}
																							
																							T with_1 = CurrentTabData.Data[i]; //DirectCast(DirectCast(RowTab.TabPages(i), NewTab).AtactchData, TabObject)
																							if (with_1.Fixed == false && with_1.BH == false)
																							{
																								StepV = (int) (Conversion.Val(with_1.StepString));
																								if (Information.IsNumeric(StartText))
																								{
																									Value = Convert.ToInt64(StartText);
																									Value = System.Convert.ToInt64(Value + System.Convert.ToInt32(Index * StepV));
																									NumberL = (int) (Conversion.Val(with_1.LengthText));
																									JiShuan = System.Convert.ToString(CommFunction.FormatByLength(Value, NumberL));
																									JiaoYanma = getCheckNumber(with_1.扩展信息1, JiShuan); // getCheckNumber(.ExportData1, JiShuan)
																									JiShuan = JiShuan + JiaoYanma;
																									JiShuan = CommFunction.TranslateText(System.Convert.ToString(with_1.Prefix)) + JiShuan + CommFunction.TranslateText(System.Convert.ToString(with_1.Suffix));
																									JiShuan = InsertChar(JiShuan, CommFunction.TranslateText(System.Convert.ToString(with_1.InsertChar)));
																									JiShuan = InsertOnPosition(JiShuan, System.Convert.ToInt32(i));
																								}
																								else
																								{
																									JiShuan = CommFunction.TranslateText(System.Convert.ToString(with_1.Prefix)) + StartText + CommFunction.TranslateText(System.Convert.ToString(with_1.Suffix));
																									JiShuan = InsertChar(JiShuan, CommFunction.TranslateText(System.Convert.ToString(with_1.InsertChar)));
																									JiShuan = InsertOnPosition(JiShuan, i);
																								}
																								if (CurrentTabData.是否补号 == false)
																								{
																									Result = Result + "\r\n" + JiShuan;
																								}
																								else //选中生成补号数据，在此进行数据处理
																								{
																									if (i < dc - 1)
																									{
																										Result = Result + "," + "\u0022" + JiShuan + "\u0022";
																									}
																									else if (i == dc - 1)
																									{
																										Result = Result + "," + "\u0022" + JiShuan + "\u0022";
																									}
																								}
																							}
																							else if (with_1.Fixed == true && with_1.BH == false)
																							{
																								if (CurrentTabData.是否补号 == false)
																								{
																									Result = Result + "\r\n" + StartText; //选中生成补号数据，在此进行数据处理
																								}
																								else
																								{
																									if (i < dc - 1)
																									{
																										Result = Result + "," + "\u0022" + StartText + "\u0022";
																									}
																									else if (i == dc - 1)
																									{
																										Result = Result + "," + "\u0022" + StartText + "\u0022";
																									}
																								}
																							}
																							else if (with_1.Fixed == false && with_1.BH == true)
																							{
																								string qishiBH = CommFunction.TranslateText(System.Convert.ToString(with_1.Prefix));
																								long BHvalue = 0;
																								if (Information.IsNumeric(qishiBH))
																								{
																									BHvalue = Convert.ToInt32(qishiBH);
																								}
																								else
																								{
																									BHvalue = 0;
																								}
																								StepV = (int) (Conversion.Val(with_1.StepString));
																								JiShuan = BHvalue + (CreatedCount / StepV);
																								if (CurrentTabData.是否补号 == false)
																								{
																									Result = Result + "\r\n" + JiShuan; //选中生成补号数据，在此进行数据处理
																								}
																								else
																								{
																									if (System.Convert.ToDouble(CreatedCount + 1) % (Conversion.Val(System.Convert.ToString(CurrentTabData.补号每行号码个数))) == 0)
																									{
																										Result = Result + "," + "\u0022" + JiShuan + "\u0022";
																									}
																								}
																							}
																						}
																						//Me.Text = Result
																						if (Result.Substring(0, 1) == ",")
																						{
																							Result = Result.Substring(1);
																						}
																						return Result;
																					}
																					catch (Exception ex)
																					{
																						throw (new Exception(ex.Message));
																					}
																				}
#endregion
																				public void Btn_Check_Click(System.Object sender, System.EventArgs e)
																				{
																					if (frmCheckData.IsDisposed)
																					{
																						frmCheckData = new frmCheckData();
																					}
																					frmCheckData.Show();
																				}
																				
																				
																				public void DataView_CellValueChanged(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
																				{
																					try
																					{
																						if (e.ColumnIndex == 1 | e.ColumnIndex == 2 && CaculateCell == false)
																						{
																							CaculateCell = true;
																							long st = 0;
																							long ft = 0;
																							try
																							{
																								st = Convert.ToInt64(DataView.Rows[e.RowIndex].Cells[1].Value);
																							}
																							catch
																							{
																								st = 0;
																							}
																							try
																							{
																								ft = Convert.ToInt64(DataView.Rows[e.RowIndex].Cells[2].Value);
																							}
																							catch
																							{
																								ft = 0;
																							}
																							if (ft == 0 & e.ColumnIndex == 1)
																							{
																								DataView.Rows[e.RowIndex].Cells[2].Value = DataView.Rows[e.RowIndex].Cells[1].Value;
																							}
																							int StepV = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
																							long Count = 0;
																							try
																							{
																								Count = System.Convert.ToInt64(DataView.Rows[e.RowIndex].Cells[3].Value);
																							}
																							catch (Exception)
																							{
																								Count = 0;
																							}
																							if (e.ColumnIndex == 1)
																							{
																								if (Count > 1)
																								{
																									if (StepV > 0)
																									{
																										DataView.Rows[e.RowIndex].Cells[2].Value = System.Convert.ToInt32(st + System.Convert.ToInt32(Count * Math.Abs(StepV))) - 1;
																									}
																									else
																									{
																										DataView.Rows[e.RowIndex].Cells[2].Value = System.Convert.ToInt32(st - System.Convert.ToInt32(Count * Math.Abs(StepV))) + 1;
																									}
																								}
																								else if (Count == 1)
																								{
																									if (st < ft)
																									{
																										DataView.Rows[e.RowIndex].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) + 1);
																									}
																									else
																									{
																										DataView.Rows[e.RowIndex].Cells[3].Value = Math.Abs(System.Convert.ToInt32(ft - st) / Math.Abs(StepV) - 1);
																									}
																								}
																							}
																							else if (e.ColumnIndex == 2)
																							{
																								if (Count > 1)
																								{
																									if (st > 0)
																									{
																										if (StepV > 0)
																										{
																											DataView.Rows[e.RowIndex].Cells[3].Value = System.Convert.ToInt32(ft - st) / Math.Abs(StepV) + 1;
																										}
																										else
																										{
																											DataView.Rows[e.RowIndex].Cells[3].Value = System.Convert.ToInt32(st - ft) / Math.Abs(StepV) + 1;
																										}
																									}
																									else
																									{
																										if (StepV > 0)
																										{
																											DataView.Rows[e.RowIndex].Cells[1].Value = System.Convert.ToInt32(ft - Count) + 1;
																										}
																										else
																										{
																											DataView.Rows[e.RowIndex].Cells[1].Value = System.Convert.ToInt32(ft + Count) - 1;
																										}
																									}
																								}
																								else
																								{
																									if (st > 0)
																									{
																										if (StepV > 0)
																										{
																											DataView.Rows[e.RowIndex].Cells[3].Value = System.Convert.ToInt32(ft - st) / Math.Abs(StepV) + 1;
																										}
																										else
																										{
																											DataView.Rows[e.RowIndex].Cells[3].Value = System.Convert.ToInt32(st - ft) / Math.Abs(StepV) + 1;
																										}
																									}
																								}
																							}
																							CaculateCell = false;
																						}
																						else if (e.ColumnIndex == 3 & e.RowIndex < DataView.Rows.Count - 1 && CaculateCell == false)
																						{
																							CaculateCell = true;
																							long st = 0;
																							long ft = 0;
																							int StepV = (int) (Conversion.Val(((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).步长.Text));
																							long Result = 0;
																							long cCount = 0;
																							try
																							{
																								st = System.Convert.ToInt64(DataView.CurrentRow.Cells[1].Value);
																							}
																							catch
																							{
																								st = 0;
																							}
																							try
																							{
																								ft = System.Convert.ToInt64(DataView.CurrentRow.Cells[2].Value);
																							}
																							catch
																							{
																								ft = 0;
																							}
																							try
																							{
																								cCount = System.Convert.ToInt64(DataView.CurrentRow.Cells[3].Value);
																							}
																							catch (Exception)
																							{
																								cCount = 0;
																							}
																							if (cCount > 0 & st > 0 & ft > 0)
																							{
																								if (StepV > 0)
																								{
																									Result = System.Convert.ToInt64(st + System.Convert.ToInt32(System.Convert.ToInt32(cCount * Math.Abs(StepV)) - 1));
																								}
																								else
																								{
																									Result = System.Convert.ToInt64(System.Convert.ToInt32(st - System.Convert.ToInt32(cCount * Math.Abs(StepV))) + 1);
																								}
																								DataView.CurrentRow.Cells[2].Value = Result;
																							}
																							else if (cCount > 0 & st == 0 & ft > 0)
																							{
																								if (StepV > 0)
																								{
																									DataView.Rows[e.RowIndex].Cells[1].Value = System.Convert.ToInt32(ft - cCount) / Math.Abs(StepV) + 1;
																								}
																								else
																								{
																									DataView.Rows[e.RowIndex].Cells[1].Value = System.Convert.ToInt32(ft + cCount) / Math.Abs(StepV) - 1;
																								}
																							}
																							CaculateCell = false;
																						}
																					}
																					catch (Exception ex)
																					{
																						MessageBox.Show(ex.Message);
																					}
																				}
																				
																				public void 复制起始号码ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					DataGridViewRow CR = DataView.CurrentRow;
																					if (CR != null)
																					{
																						CR.Cells[2].Value = CR.Cells[1].Value;
																					}
																					else
																					{
																						Interaction.MsgBox("未选择任何行，请确保数据表中有数据，并选中其中的一列！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
																					}
																				}
																				
																				public void 删除当前行ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					try
																					{
																						DataGridViewRow cr = DataView.CurrentRow;
																						DataView.Rows.Remove(cr);
																						for (var i = 0; i <= DataView.Rows.Count - 1; i++)
																						{
																							DataView.Rows[i].Cells[0].Value = i + 1;
																						}
																						DataView.DataSource = ds.Tables[0].DefaultView;
																					}
																					catch (Exception ex)
																					{
																						Interaction.MsgBox(ex.Message, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "错误");
																					}
																				}
																				
																				public void 清空所有数据ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					try
																					{
																						ds.Tables[0].Rows.Clear();
																						DataView.DataSource = ds.Tables[0].DefaultView;
																					}
																					catch (Exception ex)
																					{
																						Interaction.MsgBox(ex.Message, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "错误");
																					}
																				}
																				
																				private void DataView_CellContentClick(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
																				{
																					
																				}
																				
																				public void 加载数据库数据ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					if (SearchFrm == null)
																					{
																						SearchFrm = new frmSearchData();
																						SearchFrm.FormClosing += SearchFrm.SearchData_FormClosing;
																						SearchFrm.Load += SearchFrm.SearchData_Load;
																					}
																					if (SearchFrm.IsDisposed)
																					{
																						SearchFrm = new frmSearchData();
																						SearchFrm.FormClosing += SearchFrm.SearchData_FormClosing;
																						SearchFrm.Load += SearchFrm.SearchData_Load;
																					}
																					if (CommFunction.Sql.ConnectionState != ConnectionState.Connecting & CommFunction.Sql.ConnectionState != ConnectionState.Open)
																					{
																						Interaction.MsgBox("程序未连接到数据，请检查数据库参数是否设置正确并连接上数据库！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
																					}
																					else
																					{
																						SearchFrm.ShowDialog(this);
																						if (CommFunction.SearchResult != null)
																						{
																							string tbName = CommFunction.SearchResult.TableName;
																							if (tbName.ToUpper() == "RemedyCode".ToUpper())
																							{
																								ds.Tables[0].Rows.Clear();
																								for (var i = 0; i <= CommFunction.SearchResult.Rows.Count - 1; i++)
																								{
																									System.Data.DataTable with_1 = ds.Tables[0];
																									DataRow NewRow = ds.Tables[0].NewRow();
																									string Value1 = "";
																									string Value2 = "";
																									string Prix = "";
																									string Suff = "";
																									Value1 = CommFunction.SearchResult.Rows[i]["StartNo"].ToString();
																									Value2 = CommFunction.SearchResult.Rows[i]["EndNo"].ToString();
																									Prix = CommFunction.SearchResult.Rows[i]["Prefixion"].ToString();
																									Suff = CommFunction.SearchResult.Rows[i]["Suffix"].ToString();
																									if (Prix != "")
																									{
																										Value1 = Value1.Substring(Prix.Length);
																										Value2 = Value2.Substring(Prix.Length);
																									}
																									if (Suff != "")
																									{
																										Value1 = Value1.Substring(0, Value1.Length - Suff.Length);
																										Value2 = Value2.Substring(0, Value2.Length - Suff.Length);
																									}
																									NewRow[1] = Value1;
																									NewRow[2] = Value2;
																									NewRow[5] = Prix;
																									NewRow[6] = Suff;
																									with_1.Rows.Add(NewRow);
																								}
																								DataView.DataSource = ds.Tables[0].DefaultView;
																								Interaction.MsgBox("数据导入成功，查找到" + System.Convert.ToString(ds.Tables[0].Rows.Count) + "条数据记录", MsgBoxStyle.Information, "提示");
																							}
																							else
																							{
																								try
																								{
																									string FunName = "";
																									ds.Tables[0].Rows.Clear();
																									DownLoadData_Script.AddCode(CommFunction.CurrentSearchData.LoadDataVBS);
																									FunName = CommFunction.getVbsSubOrFunName(CommFunction.CurrentSearchData.LoadDataVBS);
																									for (var i = 0; i <= CommFunction.SearchResult.Rows.Count - 1; i++)
																									{
																										System.Data.DataTable with_2 = ds.Tables[0];
																										DataRow NewRow = ds.Tables[0].NewRow();
																										DataRow SearchRow = CommFunction.SearchResult.Rows[i];
																										ArrayList Param = getVBSParam(SearchRow);
																										string TmpR = "";
																										string[] Result = null;
																										try
																										{
																											TmpR = System.Convert.ToString(DownLoadData_Script.Run(FunName, Param, ((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).前缀, ((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData)).后缀));
																										}
																										catch (Exception ex)
																										{
																											Interaction.MsgBox("VBS脚本运行错误：" + "\r\n" + ex.Message, MsgBoxStyle.Critical, "提示");
																											return ;
																										}
																										if (!string.IsNullOrEmpty(TmpR))
																										{
																											Result = TmpR.Split('|');
																											for (var j = 1; j <= Result.Length; j++)
																											{
																												try
																												{
																													if (j < NewRow.Table.Columns.Count)
																													{
																														if (j != 3)
																														{
																															NewRow[j] = Result[j - 1].ToString();
																														}
																													}
																												}
																												catch
																												{
																												}
																											}
																											ds.Tables[0].Rows.Add(NewRow);
																										}
																									}
																									DataView.DataSource = ds.Tables[0].DefaultView;
																									Interaction.MsgBox("数据导入成功，查找到" + System.Convert.ToString(ds.Tables[0].Rows.Count) + "条数据记录", MsgBoxStyle.Information, "提示");
																								}
																								catch (Exception ex)
																								{
																									Interaction.MsgBox("数据导入失败,请检查加载数据VBS代码：" + "\r\n" + ex.Message, MsgBoxStyle.Critical, "错误");
																								}
																							}
																						}
																					}
																				}
																				private ArrayList getVBSParam(DataRow data)
																				{
																					try
																					{
																						ArrayList Result = new ArrayList();
																						int Rc = 0;
																						if (data == null)
																						{
																							return null;
																						}
																						Rc = data.Table.Columns.Count;
																						for (var i = 0; i <= Rc - 1; i++)
																						{
																							Result.Add(data[System.Convert.ToInt32(i)].ToString());
																						}
																						return Result;
																					}
																					catch
																					{
																						return null;
																					}
																				}
#region 生成数据，格式化
																				/// <summary>
																				/// 校验码计算函数
																				/// </summary>
																				/// <param name="CheckObj"></param>
																				/// <param name="mValue"></param>
																				/// <remarks></remarks>
																				public string getCheckNumber(object CheckObj, string mValue)
																				{
																					CommFunction.CheckMode SelCheck = (CommFunction.CheckMode) CheckObj;
																					if (string.IsNullOrEmpty(SelCheck.CheckFunName))
																					{
																						return "";
																					}
																					else
																					{
																						string Result = "";
																						if (string.IsNullOrEmpty(SelCheck.CheckCode))
																						{
																							Result = System.Convert.ToString(Interaction.CallByName(AlreadyWriteCode, SelCheck.CheckFunName, CallType.Method, mValue));
																						}
																						else
																						{
																							Result = System.Convert.ToString(CommFunction.CheckScript.Run(SelCheck.CheckFunName, ref mValue));
																						}
																						return Result;
																					}
																				}
																				//插入字符
																				public string InsertChar(string Value, string InsertStr)
																				{
																					string Result = "";
																					if (string.IsNullOrEmpty(Value))
																					{
																						return Value;
																					}
																					for (var i = 0; i <= Value.Length - 1; i++)
																					{
																						Result = Result + Value.Substring(i, 1) + InsertStr;
																					}
																					return Result;
																				}
																				/// <summary>
																				/// 在指定位置插入特殊字符
																				/// </summary>
																				/// <param name="Value">要出入字符的字符串</param>
																				/// <param name="TabIndex">数据行</param>
																				/// <returns></returns>
																				/// <remarks></remarks>
																				public string InsertOnPosition(string Value, int TabIndex)
																				{
																					try
																					{
																						T with_1 = CurrentTabData.Data[TabIndex]; //DirectCast(DirectCast(RowTab.TabPages(TabIndex), NewTab).AtactchData, TabObject)
																						// If String.IsNullOrEmpty(.插入字符.Text) Then
																						int EffectI = 0;
																						ArrayList tmpList = new ArrayList();
																						string tmpStr = "";
																						string Result = "";
																						int InsertP = 0;
																						string CheckTmp = "";
																						int Eff = 0;
																						string INsertString = CommFunction.TranslateText(System.Convert.ToString(with_1.InsertChar));
																						if (!string.IsNullOrEmpty(INsertString))
																						{
																							EffectI = INsertString.Length + 1; //.插入字符.Text.Length + 1
																						}
																						else
																						{
																							EffectI = 1;
																						}
																						for (var i = 0; i <= Value.Length - 1; i++)
																						{
																							tmpList.Add(Value.Substring(i, 1));
																						}
																						for (var i = 0; i <= with_1.InsertPosition.Count - 1; i++)
																						{
																							tmpStr = System.Convert.ToString(with_1.InsertPosition.Item(i));
																							if (tmpStr != "")
																							{
																								if (Conversion.Val(tmpStr) > 0)
																								{
																									try
																									{
																										InsertP = (int) (Conversion.Val(tmpStr) * EffectI - EffectI);
																										if (i > 0) //检查在这个位置插入字符前是否已经在有字符插入，重新计算插入字符位置
																										{
																											Eff = 0;
																											for (var j = 0; j <= i - 1; j++)
																											{
																												CheckTmp = System.Convert.ToString(with_1.InsertPosition(j)); //.字符位置(j).Text
																												if (Conversion.Val(tmpStr) > Conversion.Val(CheckTmp) && Conversion.Val(tmpStr) > 0 && Conversion.Val(CheckTmp) > 0)
																												{
																													Eff++;
																												}
																											}
																										}
																										tmpList.Insert(InsertP + Eff, CommFunction.TranslateText(System.Convert.ToString(with_1.InsertCharAtPostion(i)))); //.字符(i).Text)
																									}
																									catch
																									{
																									}
																								}
																							}
																						}
																						for (var i = 0; i <= tmpList.Count - 1; i++)
																						{
																							Result += tmpList[System.Convert.ToInt32(i)].ToString();
																						}
																						return Result;
																						//  End If
																					}
																					catch
																					{
																						return "";
																					}
																				}
#endregion
																				public void 初始化设置ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					if (RowTab.TabPages.Count > 1)
																					{
																						for (var i = 1; i <= RowTab.TabPages.Count - 1; i++)
																						{
																							RemoveTab();
																						}
																					}
																					TabObject with_1 = ((TabObject) (((NewTab) (RowTab.TabPages[0])).AtactchData));
																					with_1.步长.Text = "1";
																					with_1.长度.Text = "8";
																					with_1.校验方式.SelectedIndex = 0;
																					with_1.后缀.Text = "";
																					with_1.前缀.Text = "";
																					with_1.固定信息.Checked = false;
																					for (var i = 0; i <= with_1.字符位置.Length - 1; i++)
																					{
																						with_1.字符位置[(int) i].Text = "";
																						with_1.字符[(int) i].Text = "";
																					}
																				}
																				
																				public void Txt_Lines_KeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
																				{
																					if (Strings.Asc(e.KeyChar) != 8)
																					{
																						if (Strings.Asc(e.KeyChar) < 48 || Strings.Asc(e.KeyChar) > 57)
																						{
																							e.Handled = true;
																						}
																					}
																				}
																				
																				public void Txt_Lines_LostFocus(object sender, System.EventArgs e)
																				{
																					if (Txt_Lines.Text == "")
																					{
																						if (Conversion.Val(Txt_Lines.Text) <= 0)
																						{
																							Txt_Lines.Text = "1";
																						}
																					}
																				}
																				
																				public void TB_LinePosition_KeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
																				{
																					if (Strings.Asc(e.KeyChar) != 8)
																					{
																						if (Strings.Asc(e.KeyChar) < 48 || Strings.Asc(e.KeyChar) > 57)
																						{
																							e.Handled = true;
																						}
																					}
																				}
#region 加载以及保存设置
																				public void 保存当前设置ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					string SaveName = Interaction.InputBox("请输入当前保存设置名称：", "输入框", "", -1, -1);
																					if (string.IsNullOrEmpty(SaveName))
																					{
																						return ;
																					}
																					List<CommFunction.SaveSetting> SetData = CommFunction.SaveData.Setting;
																					if (SetData == null)
																					{
																						SetData = new List<CommFunction.SaveSetting>();
																						SetData.Add(ReadCurrentSetting(SaveName));
																					}
																					else
																					{
																						for (var i = 0; i <= SetData.Count - 1; i++)
																						{
																							if (SaveName.ToUpper() == SetData[System.Convert.ToInt32(i)].SaveName.ToUpper)
																							{
																								Interaction.MsgBox("保存名称已经存在，请重新设置！", MsgBoxStyle.Information, "提示");
																							}
																							return ;
																						}
																						SetData.Add(ReadCurrentSetting(SaveName));
																					}
																					CommFunction.SaveData.Setting = SetData;
																					SaveSetting();
																					frmList.AddItem(SaveName, SetData[SetData.Count - 1]);
																					if (CommFunction.SaveData.Setting.Count > 0)
																					{
																						Tool_ListButton.Enabled = true;
																					}
																				}
																				private CommFunction.SaveSetting ReadCurrentSetting(string SaveName)
																				{
																					CommFunction.SaveSetting tmpSet = new CommFunction.SaveSetting();
																					tmpSet.SaveName = SaveName;
																					tmpSet.TabCount = RowTab.TabPages.Count;
																					tmpSet.Data = getTabData();
																					tmpSet.补号每行号码个数 = (int) (Conversion.Val(this.TB_BHlineCount.Text));
																					tmpSet.黑线位置 = (int) (Conversion.Val(this.TB_LinePosition.Text));
																					tmpSet.每组行数 = (int) (Conversion.Val(this.Txt_Lines.Text));
																					tmpSet.是否补号 = this.NoWrap.Checked;
																					tmpSet.是否加黑线 = this.CH_AddLine.Checked;
																					return tmpSet;
																				}
																				private List<CommFunction.TabSaveData> getTabData()
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					List<CommFunction.TabSaveData> Result = new List<CommFunction.TabSaveData>();
																					for (var i = 0; i <= RowTab.TabPages.Count - 1; i++)
																					{
																						CommFunction.TabSaveData tmpTab = new CommFunction.TabSaveData();
																						TabObject with_1 = ((TabObject) (((NewTab) (RowTab.TabPages[i])).AtactchData));
																						tmpTab.StartNumberSelected = with_1.起始号.SelectedIndex;
																						tmpTab.StartNumberText = with_1.起始号.Text;
																						tmpTab.FinishNumberText = with_1.终止号.Text;
																						tmpTab.StepString = with_1.步长.Text;
																						tmpTab.LengthText = with_1.长度.Text;
																						tmpTab.CheckModeSelected = with_1.校验方式.SelectedIndex;
																						tmpTab.Prefix = with_1.前缀.Text;
																						tmpTab.Suffix = with_1.后缀.Text;
																						tmpTab.InsertChar = with_1.插入字符.Text;
																						tmpTab.InsertPosition = new ArrayList();
																						tmpTab.InsertCharAtPostion = new ArrayList();
																						for (var j = 0; j <= with_1.字符位置.Length - 1; j++)
																						{
																							tmpTab.InsertPosition.Add(with_1.字符位置[(int) j].Text);
																							tmpTab.InsertCharAtPostion.Add(with_1.字符[(int) j].Text);
																						}
																						tmpTab.Fixed = with_1.固定信息.Checked;
																						tmpTab.扩展信息1 = with_1.ExportData1;
																						tmpTab.扩展信息2 = with_1.ExportData2;
																						tmpTab.BH = with_1.本号计算.Checked;
																						Result.Add(tmpTab);
																					}
																					return Result;
																				}
																				private void LoadTabSetting()
																				{
																					List<CommFunction.SaveSetting> TabData = CommFunction.SaveData.Setting;
																					if (TabData != null)
																					{
																						for (var i = 0; i <= TabData.Count - 1; i++)
																						{
																							frmList.AddItem(System.Convert.ToString(TabData[i].SaveName), TabData[i]);
																						}
																					}
																				}
																				public void HandleMenuListClick(object SelectedData)
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					if (SelectedData != null)
																					{
																						CommFunction.SaveSetting ItemObj = (CommFunction.SaveSetting) SelectedData;
																						int tCount = ItemObj.TabCount;
																						if (tCount < RowTab.TabPages.Count)
																						{
																							for (var i = 1; i <= (RowTab.TabPages.Count - tCount + 1); i++)
																							{
																								if (RowTab.TabPages.Count > tCount)
																								{
																									RemoveTab();
																								}
																								else
																								{
																									break;
																								}
																							}
																						}
																						else if (tCount > RowTab.TabPages.Count)
																						{
																							for (var i = 1; i <= (tCount - RowTab.TabPages.Count); i++)
																							{
																								AddTabPage(RowTab.TabPages.Count);
																								RowTab.SelectedIndex = RowTab.TabPages.Count - 1;
																							}
																						}
																						for (var i = 0; i <= tCount - 1; i++)
																						{
																							TabObject with_2 = ((TabObject) (((NewTab) (RowTab.TabPages[i])).AtactchData));
																							with_2.起始号.SelectedIndex = System.Convert.ToInt32(ItemObj.Data[i].StartNumberSelected);
																							if (i > 0)
																							{
																								with_2.终止号.Text = System.Convert.ToString(ItemObj.Data[i].FinishNumberText);
																							}
																							with_2.步长.Text = System.Convert.ToString(ItemObj.Data[i].StepString);
																							with_2.长度.Text = System.Convert.ToString(ItemObj.Data[i].LengthText);
																							with_2.校验方式.SelectedIndex = System.Convert.ToInt32(ItemObj.Data[i].CheckModeSelected);
																							with_2.前缀.Text = System.Convert.ToString(ItemObj.Data[i].Prefix);
																							with_2.后缀.Text = System.Convert.ToString(ItemObj.Data[i].Suffix);
																							with_2.插入字符.Text = System.Convert.ToString(ItemObj.Data[i].InsertChar);
																							for (var j = 0; j <= with_2.字符位置.Length - 1; j++)
																							{
																								with_2.字符位置[(int) j].Text = ItemObj.Data[i].InsertPosition(j).ToString();
																								with_2.字符[(int) j].Text = ItemObj.Data[i].InsertCharAtPostion(j).ToString();
																							}
																							with_2.固定信息.Checked = System.Convert.ToBoolean(ItemObj.Data[i].Fixed);
																							with_2.本号计算.Checked = System.Convert.ToBoolean(ItemObj.Data[i].BH);
																						}
																					}
																					EventArgs e = new EventArgs();
																					HandleTextChange(null, e);
																				}
#endregion
#region 从Excel导入数据
																				private void Import_Excel()
																				{
																					try
																					{
																						string gFileName = "";
																						ImportFromExcel Rx = new ImportFromExcel(ds.Tables[0]);
																						gFileName = open_File();
																						if (File.Exists(gFileName))
																						{
																							Rx.ReadFile(gFileName);
																						}
																					}
																					catch (Exception ex)
																					{
																						Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "错误");
																					}
																				}
																				public string open_File()
																				{
																					OpenFile.Title = "选择数据文件";
																					OpenFile.Filter = "Excel97-03(*.xls)|*.xls|(Excel2007(*.xlsx)|*.xlsx";
																					OpenFile.FileName = "";
																					OpenFile.CheckFileExists = true;
																					if (OpenFile.ShowDialog() == Windows.Forms.DialogResult.OK)
																					{
																						return OpenFile.FileName;
																					}
																					else
																					{
																						return "";
																					}
																				}
																				
																				public void 导入数据ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					Import_Excel();
																				}
																				
																				public void 退出ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					this.Close();
																				}
																				
																				public void ToolStripMenuItem1_Click(System.Object sender, System.EventArgs e)
																				{
																					SystemSet.Default.Show();
																				}
#endregion
#region 设置控件
																				public void ChangeObjEnabled(bool mEnabled)
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					DataView.ReadOnly = !mEnabled;
																					if (mEnabled == true)
																					{
																						DataView.Columns[0].ReadOnly = true;
																						for (var i = 1; i <= DataView.Columns.Count - 2; i++)
																						{
																							DataView.Columns[i].ReadOnly = false;
																						}
																						DataView.Columns["状态"].ReadOnly = true;
																					}
																					RowTab.Enabled = mEnabled;
																					Txt_Lines.Enabled = mEnabled;
																					SaveFile.Enabled = mEnabled;
																					CH_AddLine.Enabled = mEnabled;
																					AppendData.Enabled = mEnabled;
																					NoWrap.Enabled = mEnabled;
																					Btn_OpenFile.Enabled = mEnabled;
																					Btn_CreateData.Enabled = mEnabled;
																					Btn_Add.Enabled = mEnabled;
																					Btn_Del.Enabled = mEnabled;
																					bool Rv = mEnabled;
																					if (CommFunction.RegionAccess && mEnabled)
																					{
																						Rv = true;
																					}
																					else
																					{
																						Rv = false;
																					}
																					this.导入数据ToolStripMenuItem.Enabled = Rv;
																					this.初始化设置ToolStripMenuItem.Enabled = Rv;
																					this.复制起始号码ToolStripMenuItem.Enabled = Rv;
																					this.加载数据库数据ToolStripMenuItem.Enabled = Rv;
																					this.清空所有数据ToolStripMenuItem.Enabled = Rv;
																					this.删除当前行ToolStripMenuItem.Enabled = mEnabled;
																					
																					foreach (ToolStripItem item in ToolStrip1.Items)
																					{
																						if (CommFunction.GetControlType(item).ToUpper() == "System.Windows.Forms.ToolStripButton".ToUpper())
																						{
																							if (item.Name.ToUpper() != "Tool_StopCreated".ToUpper() && item.Name.ToUpper() != "Tool_Exit".ToUpper() && item.Name.ToUpper() != "Tool_ConnectDataBase".ToUpper() && item.Name.ToUpper() != "Tool_HexadecimalConversion".ToUpper() && item.Name.ToUpper() != "Tool_FindData".ToUpper())
																							{
																								item.Enabled = mEnabled;
																							}
																						}
																					}
																					if (mEnabled == true)
																					{
																						Tool_FormatSet.Enabled = Rv;
																						Tool_OpenSearchFrm.Enabled = Rv;
																						Tool_Save.Enabled = Rv;
																						Tool_ConnectDataBase.Enabled = Rv;
																					}
																				}
																				public void ChangeRegionObjEnabled()
																				{
																					//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
																					bool Rv = false;
																					if (CommFunction.RegionAccess)
																					{
																						Rv = true;
																					}
																					else
																					{
																						Rv = false;
																					}
																					this.导入数据ToolStripMenuItem.Enabled = Rv;
																					this.初始化设置ToolStripMenuItem.Enabled = Rv;
																					// Me.复制起始号码ToolStripMenuItem.Enabled = Rv
																					this.加载数据库数据ToolStripMenuItem.Enabled = Rv;
																					this.清空所有数据ToolStripMenuItem.Enabled = true;
																					this.删除当前行ToolStripMenuItem.Enabled = true;
																					Tool_FormatSet.Enabled = Rv;
																					Tool_OpenSearchFrm.Enabled = Rv;
																					Tool_Save.Enabled = Rv;
																					Tool_ConnectDataBase.Enabled = Rv;
																					this.修改数据库地址ToolStripMenuItem.Enabled = Rv;
																					this.查找所有设置ToolStripMenuItem.Enabled = Rv;
																					this.ToolStripMenuItem1.Enabled = Rv;
																					this.链接数据库ToolStripMenuItem.Enabled = Rv;
																					this.Menu_Region.Enabled = !Rv;
																					this.保存当前设置ToolStripMenuItem.Enabled = Rv;
																					this.Tool_HexadecimalConversion.Enabled = Rv;
																					this.Tool_FindData.Enabled = Rv;
																					this.Tool_App.Enabled = Rv;
																					this.CB_ExportOutPut.Enabled = Rv;
																				}
#endregion
																				public void RemoveSetting(string ShowName)
																				{
																					frmList.Remove(ShowName);
																				}
																				public void ModifySetting(string FindName, string ModifyName)
																				{
																					frmList.ModifyName(FindName, ModifyName);
																				}
																				public void ReLoadCheckMode()
																				{
																					//先清空原有数据，再进行加载
																					for (var i = 0; i <= RowTab.TabPages.Count - 1; i++)
																					{
																						((TabObject) (((NewTab) (RowTab.TabPages[i])).AtactchData)).校验方式.Items.Clear();
																					}
																					CommFunction.CheckData.Clear();
																					//加载新数据
																					CommFunction.LoadCheckMode();
																					for (var i = 0; i <= RowTab.TabPages.Count - 1; i++)
																					{
																						AddCheckName(((TabObject) (((NewTab) (RowTab.TabPages[i])).AtactchData)).校验方式);
																					}
																				}
																				
																				public void 查找所有设置ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					SystemSet frmSet = new SystemSet(2);
																					frmSet.Show();
																				}
																				
																				private void DataView_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
																				{
																					
																				}
																				
																				public void CheckDescription_KeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
																				{
																					e.Handled = true;
																				}
																				private void LoadMenuColor()
																				{
																					CommFunction.MenuSkinRender.BackLeftColor1 = Color.White;
																					CommFunction.MenuSkinRender.BackLeftColor2 = Color.FromArgb(255, 245, 245, 245);
																					CommFunction.MenuSkinRender.BackLeftColor3 = Color.FromArgb(255, 230, 230, 230);
																					CommFunction.MenuSkinRender.BackLeftColor4 = Color.White;
																					CommFunction.MenuSkinRender.ItemBorderColor = Color.FromArgb(255, 190, 190, 190);
																					CommFunction.MenuSkinRender.ItemDownColor1 = Color.White;
																					CommFunction.MenuSkinRender.ItemDownColor2 = Color.FromArgb(255, 200, 200, 200);
																					CommFunction.MenuSkinRender.ItemDownColor3 = Color.FromArgb(255, 225, 225, 225);
																					CommFunction.MenuSkinRender.ItemDownColor4 = Color.FromArgb(255, 235, 235, 235);
																					CommFunction.MenuSkinRender.ItemDownColor5 = Color.FromArgb(255, 245, 245, 245);
																					CommFunction.MenuSkinRender.MenuBorderColor = Color.FromArgb(255, 160, 160, 160);
																					CommFunction.MenuSkinRender.ItemColor1 = Color.White;
																					CommFunction.MenuSkinRender.ItemColor2 = Color.FromArgb(230, 230, 230);
																					CommFunction.MenuSkinRender.ItemColor3 = Color.FromArgb(210, 210, 210);
																					CommFunction.MenuSkinRender.ItemColor4 = Color.FromArgb(200, 200, 200);
																					CommFunction.MenuSkinRender.ItemColor5 = Color.FromArgb(210, 210, 210);
																					CommFunction.MenuSkinRender.MenuBarColor1 = Color.White;
																					CommFunction.MenuSkinRender.MenuBarColor2 = Color.FromArgb(255, 240, 240, 240);
																					CommFunction.MenuSkinRender.MenuBarColor3 = Color.FromArgb(255, 230, 230, 230);
																					CommFunction.MenuSkinRender.MenuBarColor4 = Color.White;
																					CommFunction.MenuSkinRender.MenuBackColor = Color.WhiteSmoke;
																					MenuStrip1.ForeColor = Color.FromArgb(56, 78, 20);
																					ToolStrip.ButtonDownBorderColor = Color.FromArgb(125, 125, 125);
																					ToolStrip.ButtondownColor1 = Color.FromArgb(180, 180, 180);
																					ToolStrip.ButtondownColor2 = Color.FromArgb(255, 255, 255);
																					ToolStrip.ButtonHoverBorderColor = Color.FromArgb(180, 180, 180);
																					ToolStrip.ButtonHoverColor1 = Color.White;
																					ToolStrip.ButtonHoverColor2 = Color.FromArgb(220, 220, 220);
																					ToolStrip.GripColor = Color.FromArgb(10, 125, 78);
																					ToolStrip.MenuLeftBackColor = Color.WhiteSmoke;
																					ToolStrip.SplitColor = Color.FromArgb(125, 125, 125);
																					ToolStrip.ToolBackColor1 = Color.FromArgb(255, 255, 255);
																					ToolStrip.ToolBackColor2 = Color.FromArgb(230, 230, 230);
																					ToolStrip.ToolBackColor3 = Color.FromArgb(230, 230, 230);
																					ToolStrip.ToolBackColor4 = Color.FromArgb(230, 230, 230);
																					ToolStrip.ToolBackColor5 = Color.FromArgb(255, 255, 255);
																					ToolStrip.ToolBorderColor = Color.FromArgb(100, 100, 100);
																					ToolStrip.ToolMenuItemBackColor = Color.WhiteSmoke;
																					ToolStrip.ToolMenuItemHoverColor1 = Color.White;
																					ToolStrip.ToolMenuItemHoverColor2 = Color.FromArgb(230, 230, 230);
																					ToolStrip.ToolMenuItemHoverColor3 = Color.FromArgb(210, 210, 210);
																					ToolStrip.ToolMenuItemHoverColor4 = Color.FromArgb(200, 200, 200);
																					ToolStrip.ToolMenuItemHoverColor5 = Color.FromArgb(210, 210, 210);
																					ToolStrip1.Renderer = ToolStrip;
																					ToolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32);
																					string tp;
																					foreach (ToolStripItem tsmi in ToolStrip1.Items)
																					{
																						tp = CommFunction.GetControlType(tsmi);
																						if (tp == "System.Windows.Forms.ToolStripButton")
																						{
																							tsmi.AutoSize = false;
																							tsmi.Size = new System.Drawing.Size(32, 32);
																							tsmi.AutoSize = true;
																						}
																					}
																					CommFunction.ChangeButtonFromFrm(GroupBox1);
																				}
																				
																				public void Tool_Save_Click(System.Object sender, System.EventArgs e)
																				{
																					保存当前设置ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Timer1_Tick(System.Object sender, System.EventArgs e)
																				{
																					ProgressSub(ChangeParam.value, ChangeParam.ProgressValue2, ChangeParam.DRowCount, ChangeParam.LineCount);
																				}
																				
																				public void Menu_About_Click(System.Object sender, System.EventArgs e)
																				{
																					string mAbout = "";
																					mAbout = "产品名称：" + Application.ProductName + "\r\n" + "文件版本：" + Application.ProductVersion + "\r\n" + "公    司：" + Application.CompanyName + "\r\n" + "作    者：莫书江（E_Mail:250933400@qq.com）";
																					Interaction.MsgBox(mAbout, MsgBoxStyle.Information, "关于");
																				}
																				
																				public void Menu_Region_Click(System.Object sender, System.EventArgs e)
																				{
																					//Me.Text = GetMac()
																					CommFunction.Registration(true);
																				}
																				
																				public void Tool_CopyStart_Click(System.Object sender, System.EventArgs e)
																				{
																					复制起始号码ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_Initalize_Click(System.Object sender, System.EventArgs e)
																				{
																					初始化设置ToolStripMenuItem_Click(sender, e);
																					HandleTextChange(sender, e);
																				}
																				
																				public void Tool_FormatSet_Click(System.Object sender, System.EventArgs e)
																				{
																					查找所有设置ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_Clear_Click(System.Object sender, System.EventArgs e)
																				{
																					清空所有数据ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_DelRow_Click(System.Object sender, System.EventArgs e)
																				{
																					删除当前行ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_ConnectDataBase_Click(System.Object sender, System.EventArgs e)
																				{
																					链接数据库ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_OpenSearchFrm_Click(System.Object sender, System.EventArgs e)
																				{
																					加载数据库数据ToolStripMenuItem_Click(sender, e);
																				}
																				
																				public void Tool_DeleteTab_Click(System.Object sender, System.EventArgs e)
																				{
																					Btn_Del_Click(sender, e);
																				}
																				
																				public void Tool_AddTab_Click(System.Object sender, System.EventArgs e)
																				{
																					Btn_Add_Click(sender, e);
																				}
																				
																				public void Tool_Import_Click(System.Object sender, System.EventArgs e)
																				{
																					Import_Excel();
																				}
																				
																				public void Tool_Create_Click(System.Object sender, System.EventArgs e)
																				{
																					Btn_CreateData_Click(sender, e);
																				}
																				
																				public void Tool_Copy_Click(System.Object sender, System.EventArgs e)
																				{
																					try
																					{
																						DataGridViewRow dataR = DataView.CurrentRow;
																						string Finshed = System.Convert.ToString(dataR.Cells[2].Value);
																						DataView.CurrentRow.Cells[1].Value = Finshed;
																					}
																					catch
																					{
																					}
																				}
																				
																				public void Tool_Exit_Click(System.Object sender, System.EventArgs e)
																				{
																					this.Close();
																				}
																				
																				public void Tool_StopCreated_Click(System.Object sender, System.EventArgs e)
																				{
																					StopCreattingData = true;
																				}
																				
																				public void Menu_CreateShortCut_Click(System.Object sender, System.EventArgs e)
																				{
																					CommFunction.CreateShotCut();
																				}
																				
																				public void Txt_Lines_TextChanged(System.Object sender, System.EventArgs e)
																				{
																					
																				}
																				
																				public void TB_BHlineCount_KeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e)
																				{
																					if (Strings.Asc(e.KeyChar) != 8)
																					{
																						if (Strings.Asc(e.KeyChar) < 48 || Strings.Asc(e.KeyChar) > 57)
																						{
																							e.Handled = true;
																						}
																					}
																				}
																				
																				public void Tool_HexadecimalConversion_Click(System.Object sender, System.EventArgs e)
																				{
																					if (frm_Convert == null)
																					{
																						frm_Convert = new frmConversion();
																					}
																					if (frm_Convert.IsDisposed)
																					{
																						frm_Convert = new frmConversion();
																					}
																					frm_Convert.Show();
																				}
																				
																				public void Form1_Resize(object sender, System.EventArgs e)
																				{
																					frmList.Left = (int) (this.Left - CommFunction.frmSettingX);
																				}
																				public void Tool_ListButton_Click(System.Object sender, System.EventArgs e)
																				{
																					sAPI.RECT lr = new sAPI.RECT();
																					int ShowLeft = 0;
																					int ShowTop = 0;
																					sAPI.GetWindowRect(this.ToolStrip1.Handle.ToInt32(), ref lr);
																					ShowLeft = lr.Right - frmList.Width - 2;
																					ShowTop = lr.Bottom - 4;
																					frmList.Left = ShowLeft;
																					frmList.Top = ShowTop;
																					frmList.ShowInTaskbar = false;
																					frmList.Show();
																					// frmList.ShowDisplay()
																				}
																				
																				public void Tool_PastClipBoardData_Click(System.Object sender, System.EventArgs e)
																				{
																					string Data = Clipboard.GetText();
																					string[] Rows = Data.Split('\n');
																					string CurrentRow = "";
																					int ColCount = 0;
																					string Err = "";
																					ds.Tables[0].Rows.Clear();
																					ColCount = ds.Tables[0].Columns.Count;
																					for (var i = 0; i <= Rows.Length - 1; i++)
																					{
																						CurrentRow = Rows[(int) i];
																						try
																						{
																							string[] CellsData = Strings.Split(CurrentRow, System.Convert.ToString("\t"), -1, (Microsoft.VisualBasic.CompareMethod) 0);
																							DataRow NewRow = ds.Tables[0].NewRow();
																							int SIndex = 0;
																							for (var j = 0; j <= CellsData.Length - 1; j++)
																							{
																								if (j < ColCount)
																								{
																									string Value = System.Convert.ToString(CellsData[(int) j].Replace(" ", "").Trim(' '));
																									if (Value != "")
																									{
																										NewRow[SIndex + 1] = Value;
																										SIndex++;
																									}
																								}
																							}
																							ds.Tables[0].Rows.Add(NewRow);
																						}
																						catch (Exception ex)
																						{
																							if (Err != "")
																							{
																								Err = Err + "\r\n" + "行" + System.Convert.ToString(i) + "错误：" + ex.Message;
																							}
																							else
																							{
																								Err = "行" + System.Convert.ToString(i) + "错误：" + ex.Message;
																							}
																						}
																					}
																					if (Err != "")
																					{
																						Interaction.MsgBox("数据添加结束，添加过程中出现错误！" + "\r\n" + Err, (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "提示");
																					}
																					else
																					{
																						Interaction.MsgBox("数据添加结束！", (int) MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "提示");
																					}
																				}
																				
																				public void Tool_FindData_Click(System.Object sender, System.EventArgs e)
																				{
																					frm_RemedyData frm = new frm_RemedyData();
																					frm.Show();
																				}
																				
																				public void 提煤单数据生成ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					frm_Timeidan frm = new frm_Timeidan();
																					frm.Show();
																				}
																				
																				public void 条码标签ToolStripMenuItem_Click(object sender, EventArgs e)
																				{
																					frmTiaomaBiaoqian frm = new frmTiaomaBiaoqian();
																					frm.Show();
																				}
																				
																				public void 进制转换ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					Tool_HexadecimalConversion_Click(sender, e);
																				}
																				
																				public void 提取号码ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					Tool_FindData_Click(sender, e);
																				}
																				
																				public void 文本编辑ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					frm_TextEdit frm = new frm_TextEdit();
																					frm.Show();
																				}
																				
																				public void Menu_Help_Click(System.Object sender, System.EventArgs e)
																				{
																					
																				}
																				
																				public void DHL标签数据ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
																				{
																					if (frm_DHLObj == null)
																					{
																						frm_DHLObj = new frm_DHL();
																					}
																					if (frm_DHLObj.IsDisposed)
																					{
																						frm_DHLObj = new frm_DHL();
																					}
																					frm_DHLObj.Show(this);
																				}
																				
																				public void 日本邮政ToolStripMenuItem_Click(object sender, EventArgs e)
																				{
																					var frmEMS = new frmJanpanEMS();
																					frmEMS.Show();
																				}
																			}
																			public class ChangeValueParam
																			{
																				public long value;
																				public int DRowCount;
																				public int LineCount;
																				private long mProgressValue2;
public long ProgressValue2
																				{
																					get
																					{
																						return mProgressValue2;
																					}
																					set
																					{
																						mProgressValue2 = value;
																					}
																				}
																			}
																		}
